<template>
	<view>
		<cu-custom bgColor="bg-blue">
			<block slot="content">学生档案</block>
		</cu-custom>
		<van-cell-group>
			<van-field :value="inputForm.name" required label="姓名" readonly=true placeholder="请输入姓名" />
			<van-field :value="inputForm.institute" required label="学院" readonly=true placeholder="请输入学院" />
			<van-field :value="inputForm.grade" required label="年级" readonly=true placeholder="请输入年级" />
			<van-field :value="inputForm.classe" required label="班级" readonly=true placeholder="请输入班级" />
			<van-field :value="inputForm.studentId" required label="学号" readonly=true placeholder="请输入学号" />
			<van-field :value="currentInstructor" required label="当前辅导员" readonly=true placeholder="请输入当前辅导员" />
			<van-field :value="currentMoraleduPoint" required label="当前德育分" readonly=true placeholder="请输入当前德育分" />
		</van-cell-group>
		<van-collapse :value="activeNames" @change="onChange()">
			<van-collapse-item title="德育加分" name="1">
				<van-cell-group v-for="(item,index) in dataList" :key="index">
			  <van-field
			    :value= item.addReason
			  	label="加分原因"
			    border = false
			  	disabled
			  />
			  <van-field
			    :value= item.addTime
			  	label="加分时间"
			    border = false
			  	disabled>
			  </van-field>
			  <van-field
			    :value= item.addState
			  	label="审核状态"
			    border = false
			  	disabled>
			  </van-field>
			  <van-field
			    :value= item.approver
			  	label="审核人"
			    border = false
			  	disabled
			  />
			  <van-field
			    :value= item.addPoint
			  	label="加分数"
			    border = false
			  	disabled
			  />
				<van-image lazy-load width="100" height="100" v-for="(src, indexs) in item.addEnclosure.split(',')"
						:key="indexs" :src="`https://suntuding.com` + src" v-if="item.addEnclosure.length >= 2" />
				</van-cell-group>
			</van-collapse-item>
			<van-collapse-item title="德育减分" name="2">
				<van-cell-group v-for="(item,index) in dataSubList" :key="index">
					<van-field :value=item.subReason label="减分原因" border=false disabled />
					<van-field :value=item.subPoint label="减分数" border=false disabled />
				</van-cell-group>
			</van-collapse-item>
		</van-collapse>
	</view>
</template>

<script>
	import { mapState } from 'vuex'
	export default {
		data() {
			return {
				inputForm: {
					id: '',
					name: '', // 姓名
					institute: '', // 学院
					grade: '', // 年级
					classe: '', // 班级
					studentId: '', // 学号
					maximum: 999999,
					minimum:-9999999
				},
				currentInstructor: '', // 当前辅导员
				currentMoraleduPoint: '', // 目前德育分
				src: '',
				dataList: [], // 德育加分数组
				dataSubList: [], // 德育减分数组
				id: '',
				activeNames: [],
				fileurl: '',
			}
		},
		computed: mapState({
			 userInfo: (state) => state.user.userInfo
		  }),
		methods: {
			// 折叠面板点击事件
			onChange(event) {
			  this.activeNames = event.detail
			},
			getInfo(){
				this.pullUser()
				this.refreshList()
			  },
			  // 获取个人信息
			pullUser(){
				this.inputForm.name = this.userInfo.name
				this.inputForm.institute = this.userInfo.office.name
				this.inputForm.grade = this.userInfo.grade
				this.inputForm.classe = this.userInfo.classn
				this.inputForm.studentId = this.userInfo.no
			},
			// 获取数据列表
			refreshList(){
				this.$http.get('/moredumain/studentMoreduMain/list',this.inputForm).then(({data})=>{
					console.log(data)
					if (data && data.success) {
						this.id = data.page.list[0].id
						this.currentInstructor=data.page.list[0].currentInstructor
						this.currentMoraleduPoint = data.page.list[0].currentMoraleduPoint
						this.detail()
					}
				})
			},
			//获取详细信息
			detail (row) {
			  this.$http.get(`/moredumain/studentMoreduMain/queryById?id=` + this.id).then(({data}) => {
					this.dataList = data.studentMoreduMain.studentMoreduViceAddList
					this.dataList.map(item => {
						item.addState = this.$dictUtils.getDictLabel("audit_status", item.addState, '-')
					})
					this.dataSubList = data.studentMoreduMain.studentMoreduViceSubList
			  })
			  console.log(this.dataList)
			}
		}
	}
</script>

<style>

</style>
